home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: jsberg@hpslap03.cern.ch (J. Scott Berg)
- Newsgroups: comp.std.c++
- Subject: Initialization of nonlocal objects with static storage duration
- Date: 17 Apr 1996 10:41:38 PDT
- Organization: CERN, European Laboratory for Particle Physics
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <Dq0071.23J@news.cern.ch>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Wed, 17 Apr 1996 08:42:37 GMT
- Apparently-To: comp-std-c++@dxnews.cern.ch
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMXUtU0y4NqrwXLNJAQHBOgH/TCelQMW+4x1FI4++SFPQpILw4WdQ0amY
- f9S+sRXhDbaQNBPqOrEe/aBe0PC55s1CvwHj1VhO9fgOsSuK1r/Txg==
- =BFJk
- Originator: austern@isolde.mti.sgi.com
-
- If one looks at section 3.6.2 of the April WP, one finds the rules
- given there for initialization of non-local objects with static
- storage duration to be the following:
-
- 1) They are initialized before the first use of any function or object
- defined in that translation unit.
- 2) The storage is zero-initialized before any other initialization
- takes place.
- 3) Objects with static storage duration initialized with constant
- expressions are initialized before any other initialization takes
- place.
- 4) The order of initialization of nonlocal objects with static storage
- duration defined in the same translation unit is the order in which
- their definition appears in the translation unit.
-
- I was told that 1) no longer appears in the draft, since it could
- become circular, among other things. What of this, if any, can I
- reasonably rely on existing in the final standard?
-
- My reason is that I wish to have classes defined in different
- translation units which register themselves with another class via an
- initialization of a global object. The class with which they register
- themselves keeps the list in a static member, which must be
- initialized before any of the other classes register themselves. I
- had attempted to do this using 1), and when that didn't work, I
- reported it as a bug and was told that 1) was no longer part of the
- standard. If I could rely on 2), for instance, I could make a global
- pointer to the list and check if it was null, for instance,
- initializing the list if it was; 3) would work similarly.
-
- Thank you very much
-
- -Scott Berg
-
- --
- J. Scott Berg email: Scott.Berg@cern.ch
- Work Phone: (41-22-)767-94-67 Real mail: CERN; SL Division; Bldg 30-2002
- Home Phone: (41-22-)783-03-15 CH-1211 Geneva 23; Switzerland
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-